//
//  WorksData.m
//  __PRODUCTNAME__
//
//  Created by LL.F on 16/09/19
//  Copyright (c) __ORGANIZATIONNAME__. All rights reserved.
//

#import "WorksData.h"
#import "WorksLike.h"
#import "WorksRelates.h"
#import "WorksTopics.h"

@implementation WorksData

+ (NSDictionary *)objectClassInArray{
    return @{@"like" : [WorksLike class], @"relates" : [WorksRelates class], @"topics" : [WorksTopics class]};
}
- (void)setValue:(id)value forKey:(NSString *)key
{
    
    [super setValue:value forKey:key];
    if ([key isEqualToString:@"like"]) {
        NSMutableArray<WorksLike *>  *secDataArray = [NSMutableArray array];
        for (NSDictionary *dic in value) {
            WorksLike *data = [WorksLike modelWithDic:dic];
            [secDataArray addObject:data];
        }
        _like = secDataArray;
    }if ([key isEqualToString:@"relates"]) {
        NSMutableArray<WorksRelates *>  *secDataArray = [NSMutableArray array];
        for (NSDictionary *dic in value) {
            WorksRelates *data = [WorksRelates modelWithDic:dic];
            [secDataArray addObject:data];
        }
        _relates = secDataArray;
    }if ([key isEqualToString:@"topics"]) {
        NSMutableArray<WorksTopics *>  *secDataArray = [NSMutableArray array];
        for (NSDictionary *dic in value) {
            WorksTopics *data = [WorksTopics modelWithDic:dic];
            [secDataArray addObject:data];
        }
        _topics = secDataArray;
    }
}
- (void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    
    if ([key isEqualToString:@"id"]) {
        _id_Data = value;
    } if ([key isEqualToString:@"description"]) {
        _description_Data = value;
    }
}
@end
